//
// C++ Interface: lcd
//
// Description: 
//
//
// Author: Ian Harris <ian@rasputin.bombercommand.org.uk>, (C) 2009
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef _LCD_H_
#define _LCD_H_

typedef enum {
	Portrait		= 0,	// Do not change these values!
	Portrait180		= 3,	// They are sent to the display
	Landscape		= 5,	// in order to set the graphics
	Landscape180	= 6		// mode of the display.
} EWindowOrientation;

typedef enum {
	cm256 = 0,
	cm65k = 1
} EColorMode;

extern EWindowOrientation Orientation;

// define boolean type
typedef enum {
	false = 0,
	true = 1
} bool;

void LCD_Init(void);
void LCD_SetBacklight( uint8_t wLevel );
void LCD_Cls(unsigned int color);
void LCD_Window(int x1, int y1, int x2, int y2); 
void LCD_Box(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned int color);
void LCD_Plot(unsigned char x1, unsigned char y1, unsigned char line_type, unsigned int color);
void LCD_CirclePoints(int x, int y, int xOfs, int yOfs, unsigned char line_type, unsigned int color);
void LCD_Draw(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2,unsigned char line_type ,unsigned int color);
void LCD_Rect(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char line_type, unsigned int color);
void LCD_Circle(int x1, int y1, int r, unsigned char fill, unsigned char line_type, unsigned int color);
void LCD_Bitmap(int x1, int y1, const prog_uint8_t pbmp[] );
void LCD_BitmapWindow(int x1, int y1, int bmx, int bmy, int bmw, int bmh, const prog_uint8_t pbmp[] );
void LCD_BitmapWindowTint(int x1, int y1, int bmx, int bmy, int bmw, int bmh, const prog_uint8_t pbmp[], char msk );
void LCD_Print(const  char* Text, unsigned char X, unsigned char Y, unsigned int ForeColor, unsigned int BackColor);
void LCD_Print_Int( int value, unsigned char len, unsigned char decimals, unsigned char X, unsigned char Y, unsigned int ForeColor, unsigned int BackColor  );
void LCD_PrintHex(char v, unsigned char X, unsigned char Y, unsigned int ForeColor, unsigned int BackColor);
void LCD_Smooth_Numbers(const char* Text, unsigned char X, unsigned char Y );
void LCD_Smooth_Int( int value, unsigned char len, unsigned char decimals, unsigned char X, unsigned char Y );


#define GLUE(a, b)     a##b
#define PORT(x)        GLUE(PORT, x)
#define PIN(x)         GLUE(PIN, x)
#define DDR(x)         GLUE(DDR, x)

#define LCD_PORT PortB  	//war B
#define LCD_CLK 1			// Clock 
#define LCD_RESET 4			// Reset Display 
#define LCD_SELECT 5		// Cable Select 
#define LCD_DC 6			// Data/Command 
#define LCD_DATA 2			// Send Data
#define LCD_BLIGHT OCR0A	// Backlight timer register

#define RGB(R,G,B) ((((R) & 0x1f) << 11) + (((G) & 0x3f) << 5) + ((B) & 0x1f))
#define SET(bit) (PORTB |= _BV(bit))
#define RESET(bit) (PORTB &= ~_BV(bit))

#define bright_blue		0b1101111011011111	//Predefined colors will make programmers life easier
#define blue			0b0000000000011111
#define dark_blue		0b0000000000010011
#define bright_yellow	0b1111111111001100	//as the display uses 65.536 colors we have to define double-bytes for each color
#define yellow			0b1111111111100000	//Check the programmers manual to learn how to define your own color
#define orange			0b1111110011000110
#define bright_red		0b1111100011100011
#define red				0b1111100000000000
#define dark_red		0b1001100000000000
#define bright_green 	s0b1001111111110011
#define green 			0b0000011111100000
#define dark_green 		0b0000001101100000
#define white 			0b1111111111111111
#define grey 			0b0011100011100111
#define black 			0b0000000000000000

#define THICK   1
#define THIN    0

#define FILL    1
#define NOFILL  0


#endif
